/*
 *               ____
 *              /\   \
 *             ___\   \___
 *            /\          \
 *            \ \___    ___\
 *        ____ \/__/\   \__/
 *       /\   \    \ \___\    klof  |  innovative web technology
 *      ___\   \___ \/___/
 *     /\          \          klib3/script.js
 *     \ \___    ___\         Load external scripts after the page is loaded
 *      \/__/\   \__/
 *          \ \___\           Copyright 2003-2006, klof
 *           \/___/           http://www.klof.net/k.lib3/
 *
 *                            requirements: klib3/xml.js
 */


/* Create the master klib3 object if she doesn't exist */
if ( typeof klib3 != "object" )
	klib3 = new ( function(){ this._child = 0 } )();



klib3.script = function()
{
	this._version = "1.0.0";
	this.init();
};
klib3.script.prototype.init = function()
{
	var aHead    = document.getElementsByTagName( "head" );
	this._head   = aHead.length > 0 ? aHead[ 0 ] : false;
	this._script = document.createElement( "script" );
	this._load   = new Array();
};
klib3.script.prototype.load = function( sURL )
{
	var sCode = klib3.xml.get( sURL, true );
	alert( sCode );
	this.create( sCode );
	return false;
};
klib3.script.prototype.create = function( sSource )
{
	if ( this._head && this._script )
	{
		oScript         = this._script.cloneNode( true );
		oScript._parent = this;
		oScript.appendChild( document.createTextNode( sSource ) );
		this._head.appendChild( oScript );
		this._load[ this._load.length ] = oScript;
	}
	return false;
};


// construct the klib3.script Object onto itself so we have access to it's members
klib3.script = new klib3.script;

